package com.tuling;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class DubboConsumerDemo  {

    // 如果consumer调用provider失败之后,方法就返回 123  ,这个123 你可以改成一个自定义的json格式的result
    //当调用失败的时候就返回降级参数给前端
    //注意,服务降级不会触发重试
    @Reference(version = "default",   mock = "force: return 123")
    private  DemoService demoService;

    public static void main(String[] args)  {
        ConfigurableApplicationContext context = SpringApplication.run(DubboConsumerDemo.class);
        DemoService demoService = context.getBean(DemoService.class);

        System.out.println((demoService.sayHello("周瑜")));//返回结果: 123
    }

}
